package is.client.controller.command;

import is.client.Locale;
import is.client.Main;
import is.common.exception.DroppingNonEmptyDepartmentException;
import is.common.interfaces.Command;

import java.io.IOException;

/**
 * @author aspr0
 *         Date: 16.05.12
 *         Time: 14:16
 */
public class DropCommand implements Command
{
    private int sectionNum;
    private String[] row;

    public DropCommand(int sectionNum, String[] row)
    {
        this.sectionNum = sectionNum;
        this.row = row;
    }

    @Override
    public void execute()
    {
        try
        {
            String droppedRowCount = Main.getController().getModel().dropRows(sectionNum, row);
            Main.getController().getUserInterface().exposeInfoMsg(droppedRowCount);
        }
        catch (DroppingNonEmptyDepartmentException e)
        {
//            e.printStackTrace();
            Main.getController().getUserInterface().exposeWarnMsg(Locale.WARN_DROPPING_NON_EMPTY_DEPARTMENT);
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        catch (ClassNotFoundException e)
        {
            e.printStackTrace();
        }
    }
}
